home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1994 October / Macformat17.cdr / Shareware City / Developers / GAL ƒ / GAL examples / power < prev    next >
Text File  |  1994-07-11  |  352b  |  23 lines

  1. ; calculates a^b
  2. ; where a is in R0=> b in R1 and the answer in R0
  3.     copy     a=>Reg0
  4.     copy    b=>reg1
  5.     jump:subroutine    power
  6.     halt
  7.     noop
  8. power
  9.     copy    reg0=>reg2        ;save the value
  10.     copy    1=>reg0
  11. looptop
  12.     compare 0=>reg1
  13.     jump:greater_equal    endit
  14.     multiply    reg2=>reg0            ; 
  15.     subtract    1=>reg1
  16.     jump:always    looptop
  17. endit
  18.     return
  19.     noop
  20. a    constant    5
  21. b    constant    4
  22.     end
  23.